package com.yunli.mall.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author yaolonglong
 * @description
 * @date 2020/8/28 9:50
 */
@Component
public class AppContext implements ApplicationContextAware {
    private static ApplicationContext appContext;

    @Override
    public void setApplicationContext(ApplicationContext arg) throws BeansException {
        appContext = arg;
    }

    public static Object getObject(String id) {
        Object object = null;
        object = appContext.getBean(id);
        return object;
    }
}
